package com.itheima.demo02;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

//字符缓冲流
public class CharClass03 {
    public static void main(String[] args) {
        BufferedReader br = null;
        try {
            br = new BufferedReader(new FileReader("day12\\c.txt"));
            //一次读取一个字符
            /*int a;
            while ((a = br.read()) != -1) {
                System.out.print((char) a);
            }*/
            //一次读取一个字符串
            char[] chars = new char[1024];
            int len;
            while ((len = br.read(chars)) != -1) {
                System.out.print(new String(chars,0,len));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if (br != null) {
                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
